package com.t1.demo.Controller;

import com.sun.deploy.net.HttpResponse;
import com.t1.demo.Share.Socket_Server;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description:
 * @Author: 杨淮尊
 * @Date: 2020/4/13
 **/
@RestController
@RequestMapping("/ScreenTeacher")
public class TeacherController {

    @GetMapping("/{SERVERPORT}")
    public static String test(HttpServletRequest request, HttpServletResponse response, @PathVariable int SERVERPORT){
        new Socket_Server(SERVERPORT).start();
        //获取共享方IP
        String teacherIP = request.getRemoteAddr();
        //提示
        System.out.println("教师端共享开始-IP为:"+teacherIP+"-Socker端口为:"+SERVERPORT+"-等待学员加入....");
        return teacherIP;
    }
}
